package kr.hkit.powerjava.chapter22.collection;

import java.util.ArrayList;
import java.util.Collections;

public class ArrayListTest {
	public static void main(String[] args) {
		ArrayList<String> arList= new ArrayList<>();
		
		arList.add("Milk");
		ArrayList<String> subList= new ArrayList<>();
		subList.add("Bread");subList.add("Butter");
		arList.addAll(subList);
		arList.add(1, "Apple");
		
		for(String str:arList){
			System.out.println(str);
		}
		Collections.sort(arList);
		System.out.println("----");
		for(String str:arList){
			System.out.println(str);
		}
	/*	Object []arr=  arList.toArray();
		for(int i=0;i<arr.length;i++){
			System.out.print(arr[i]+"\t");
		}
		System.out.println();
		String []strArr= new String[arList.size()];//배열의 사이즈만큼 메모리 확보하고 
		arList.toArray(strArr);
		for (int i = 0; i < strArr.length; i++) {
			System.out.print(strArr[i]+"\t");
		}
		System.out.println();
		arList.clear();
		System.out.println("Empty?"+arList.isEmpty());//clear 했으므로.
		boolean result=arList.contains("Bread");
		arList.remove(1);
		arList.remove("Bread");//삭제
		arList.clear();//전체삭제
		System.out.println(result);	
		
		for(String str:arList){
			System.out.println(str);
		}
		System.out.println("------------------------");
		for(int i=0; i<arList.size();i++){
			System.out.println(arList.get(i));
		}*/
	}
}
